package com.hengxinguotong.hxgtwygsp.ui.supervise.warning.property;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.constraint.Group;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hengxinguotong.hxgtwygsp.R;
import com.hengxinguotong.hxgtwygsp.model.PropertyDeduct;
import com.hengxinguotong.hxgtwygsp.ui.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.OnClick;

public class WarningPropertyFragment extends BaseFragment implements WarningPropertyContract.IView
{
    @Inject
    WarningPropertyContract.IPresenter mPresenter;
    @BindView(R.id.warning_local_name)
    TextView warningLocalName;
    @BindView(R.id.warning_good_group)
    Group warningGoodGroup;
    @BindView(R.id.warning_local_score)
    TextView warningLocalScore;
    @BindView(R.id.warning_deduct_total)
    TextView warningDeductTotal;
    @BindView(R.id.warning_local_card)
    ImageView warningLocalCard;
    @BindView(R.id.warning_local_card_name)
    TextView warningLocalCardName;
    @BindView(R.id.warning_deduct_group)
    Group warningDeductGroup;
    @BindView(R.id.warning_all_score)
    TextView warningAllScore;
    @BindView(R.id.warning_card)
    TextView warningCard;
    @BindView(R.id.warning_all_region)
    TextView warningAllRegion;
    @BindView(R.id.warning_recycler)
    RecyclerView warningRecycler;

    private List<PropertyDeduct> propertyDeductList = new ArrayList<>();;
    private WarningPropertyAdapter propertyDeductAdapter;

    public WarningPropertyFragment()
    {
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState)
    {
        super.onActivityCreated(savedInstanceState);
        mPresenter.bindView(this);
    }

    @Override
    public void onDestroy()
    {
        super.onDestroy();
        mPresenter.dropView();
    }

    @Override
    public int getLayoutResId()
    {
        return R.layout.fragment_warning_property;
    }

    @Override
    public void init()
    {
        mockView();
        warningRecycler.setNestedScrollingEnabled(false);
        warningRecycler.setFocusableInTouchMode(false);
        LinearLayoutManager llm = new LinearLayoutManager(getContext());
        llm.setOrientation(LinearLayoutManager.VERTICAL);
        warningRecycler.setLayoutManager(llm);
        propertyDeductAdapter = new WarningPropertyAdapter(R.layout.item_property_deduct,propertyDeductList);
        warningRecycler.setAdapter(propertyDeductAdapter);
    }

    private void mockView() {

        propertyDeductList.add(new PropertyDeduct("1. 武汉今天物业管理有限公司", "30"));
        propertyDeductList.add(new PropertyDeduct("2.湖北紫荆物业发展有限公司", "25"));
        propertyDeductList.add(new PropertyDeduct("3.深圳市彩生活物业管理有限公司武汉", "25"));
        propertyDeductList.add(new PropertyDeduct("4.武汉国金物业管理有限责任公司", "25"));
    }

    @OnClick({R.id.warning_all_score, R.id.warning_card, R.id.warning_all_region})
    public void onViewClicked(View view)
    {
        switch (view.getId())
        {
            case R.id.warning_all_score:
                break;
            case R.id.warning_card:
                break;
            case R.id.warning_all_region:
                break;
        }
    }


}
